#include <cstdio>
#include <vector>
#include <map>
#define LOCAL
using namespace std;
int fun1(vector<int>::iterator begin, vector<int>::iterator end)
{
    int max = 0, value = 0;
    map<int, int> m;
    for (vector<int>::iterator it = begin; it != end; it++)
    {
        m[*it] = 0;
    }
    for (vector<int>::iterator it = begin; it != end; it++)
    {
        m[*it]++;
    }
    map<int, int>::iterator it = m.begin();
    for (; it != m.end(); it++)
    {
        if (it->second > max)
        {
            max = it->second;
            value = it->first;
        }
    }
    return value;
}
#if 0
/*
这里我用桶排序，出错了，因为题目的范围太大了无法开辟那么多内存空间来当桶。
*/
int fun(vector<int>::iterator begin, vector<int>::iterator end)
{
    int n = end - begin, max = 0;
    int book[n] = {0};
    for (; begin != end; begin++)
    {
        book[*begin]++;
        // printf("%d\n",*begin);
    }
    for (int i = 1; i <= n; i++)
    {
        if (book[i] > book[max])
            max = i;
    }
    return max;
}
#endif
int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m, x, y, f;
    scanf("%d%d", &n, &m);
    vector<int> v(n), op;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &v[i]);
    }
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &f, &x, &y);
        if (f == 0)
        {
            int rus = fun1(v.begin() + x - 1, v.begin() + y);
            op.push_back(rus);
        }
        else if (f == 1)
        {
            v[x - 1] = y;
        }
    }
    for (vector<int>::iterator it = op.begin(); it != op.end(); it++)
    {
        printf("%d\n", *it);
    }
    return 0;
}